n1 = 20;
n2 = 25;
alpha = 0.01
# x=rnorm(n1, mean=10, sd=1.3)
# y=rnorm(n2, mean=11.28, sd=1.2)
x = c(10.1320805165575, 9.23598639172565, 9.64371692751627, 11.1264082843027, 
      10.2575600917075, 12.3708781941051, 13.3713465542873, 9.5711563393744, 
      7.82591529100095, 9.00723859212856, 9.85705758528357, 9.88563315736863, 
      10.0949525492499, 11.9456490468973, 10.4209338697923, 9.93712250253579, 
      7.82314716066258, 10.9277733055979, 9.09442568774782, 8.41492507607542
)
y = c(9.43839559858346, 10.3660822581241, 10.8241206787372, 10.8877221281085, 
      14.1876839658396, 9.37710019157516, 11.4805830204559, 12.0306394164864, 
      9.7763366354459, 12.8969455060302, 10.8374396545881, 13.8963567011139, 
      10.5158151776311, 10.1147719278434, 12.6268440831923, 12.2175971537633, 
      12.0236871751922, 11.5048584668809, 10.8953765853834, 10.4779182774787, 
      10.9435457356089, 11.3747378549039, 11.1033322539869, 12.7066545990322, 
      11.4940575225886)



t.test(x, y=y, paired = FALSE, var.equal = FALSE, alternative = "less", conf.level = 1-alpha)

# druha cast 
xVar = sd(x)^2 ; yVar = sd(y)^2
dfDivider = ((xVar/n1)^2/(n1-1))+((yVar/n2)^2/(n2-1))
df = (xVar/n1 + yVar/n2)^2 / dfDivider
#df = round(df)
t = (mean(x) - mean(y))/sqrt(xVar/n1 + yVar/n2)
pValue = 1 - pt(t, df=df, lower.tail = FALSE, log.p = FALSE)
qt = - qt(p=1 - alpha, df=df)
t
qt
df
pValue
